package com.wu.ssm.mybatis;

/**
 * Created by wzf on 2018/11/13/013.
 */
public class DefaultSqlSessionFactory implements MySqlSessionFactory {

    //sqlSessionFactory持有配置对象
    private final MyConfiguration configuration;

    public DefaultSqlSessionFactory(MyConfiguration configuration) {
        this.configuration = configuration;
    }

    @Override
    public MyDefaultSqlsession openSession() {
        return openSessionFromDataSource(true);
    }

    @Override
    public MyDefaultSqlsession openSession(boolean autoCommit) {
        return openSessionFromDataSource(autoCommit);
    }

    private MyDefaultSqlsession openSessionFromDataSource(boolean autoCommit){
        return  new MyDefaultSqlsession(configuration,autoCommit);
    }

}
